package algorithm;

/**
 * @description: 冒泡排序
 * @author: apple
 * @date:  2021/11/17 11:46 下午
 * @version 1.0
 **/
public class BubbleSort {

    public static void main(String[] args) {

        int[] nums = {8,2,6,1,12,5,9};


        for (int i = 0; i < nums.length; i++) {
            for (int j = 0; j < nums.length -1 - i ; j++) {
                if (nums[j] > nums[j + 1]) {
                    int t = nums[j];
                    nums[j] = nums[j + 1];
                    nums[j + 1] = t;
                }
            }
        }

        for (int i = 0; i < nums.length; i++) {
            System.out.println(nums[i]);
        }
    }
}
